// stores/alarm.store.ts
import { defineStore } from 'pinia'
import request from '@/utils/request'

export const useAlarmStore = defineStore('alarm', {
  state: () => ({
    totalAlarms: 0
  }),
  actions: {
    async fetchTotalAlarms() {
      try {
        const response = await request.get('/manager/getAllManualViewToday')
        this.totalAlarms = response.data.length
      } catch (error) {
        console.error('获取告警数量失败:', error)
        this.totalAlarms = 0
      }
    },
    setTotalAlarms(count: number) {
      this.totalAlarms = count
    }
  }
})